/**
 * 
 */
package it.unical.canonaco.rende.igpe.game.cbv.logiclayer.engine.component.player;

import it.unical.canonaco.rende.igpe.game.cbv.logiclayer.engine.component.pawn.Character;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * @author Massimo Canonaco
 *
 */
public class SimplePlayer {

	static public int MAX_CHARACTERS = 20;
	
	protected String nickname;
	protected List<Character> characters;
	protected int gold = 12000;
	

	public SimplePlayer()
	{
		characters = Collections.synchronizedList(new ArrayList<Character>());
//		characters = new LinkedList<>();
	}
	/**
	 * @return the nickname
	 */
	public String getNickname() {
		return nickname;
	}
	/**
	 * @param nickname the nickname to set
	 */
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	
	public int getGold() {
		return gold;
	}
	public void setGold(int gold) {
		this.gold = gold;
	}
	
	/**
	 * @return the characters
	 */
	public List<Character> getCharacters() {
		return characters;
	}
	/**
	 * @param characters the characters to set
	 */
	public void setCharacters(List<Character> characters) {
		this.characters = characters;
	}
	
	/** */
	public void addCharacter(Character character)
	{
		characters.add(character);
		character.setOwner(this);
	}
	
	public void addGold(float gold) {
		this.gold += gold;
	}
	
	public void subtractGold(float gold) {
		this.gold -= gold;
	}
	
	@Override
	public boolean equals(Object arg0) 
	{
		if(arg0 instanceof SimplePlayer)
		{
			return nickname.equals(((SimplePlayer)arg0).nickname);
		}
		
		return super.equals(arg0);
	}
}
